package PTA_JAVA.Object.demo5;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n1= sc.nextInt();
        sc.nextLine();
        ArrayList<PersonOverride> po = new ArrayList<PersonOverride>();
        for(int i=0;i<n1;i++){
            po.add(new PersonOverride());
        }
        int n2= sc.nextInt();
        sc.nextLine();
        int count=0;
        boolean f=true;
        for(int i=0;i<n2;i++){
            f=true;
            PersonOverride a = new PersonOverride(sc.next(),sc.nextInt(),sc.nextBoolean());
            sc.nextLine();
            for(PersonOverride j:po){
                if(j.equals(a)){
                    f=false;
                    break;
                }
            }
            if(f){
                po.add(a);
                count++;
            }
        }
        for(PersonOverride p:po){
            System.out.println(p.toString().replace("[","").replace("]",""));
        }
        System.out.println(count);
        System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
    }
}
class PersonOverride {

    private String name;
    private  int age;
    private  boolean gender;

    public PersonOverride() {
        this("default",1,true);
    }

    public PersonOverride(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }


    @Override
    public String toString() {
        return name + "-" + age + "-" + gender;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PersonOverride that = (PersonOverride) o;
        return age == that.age &&
                gender == that.gender &&
                name.equals(that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, gender);
    }

}


